home *** CD-ROM | disk | FTP | other *** search
/ PC World 2004 December / PCWorld_2004-12_cd.bin / software / temacd / tiny / tf6pro-6[1].0.140.exe / Tiny Firewall Pro 6.0.msi / Options.js < prev    next >
Encoding:
JavaScript  |  2004-07-20  |  18.0 KB  |  598 lines

  1. /*//////////////////////////////////////////////////////////////////////
  2. filename:         options.js
  3. copyright(c):     2002, 2003 Tiny Software Inc (http://www.tinysoftware.com)
  4. author:         Jozef Palocko (jpalocko@tinysoftware.com)
  5. product:         Tiny Personal Firewall 5.x
  6. description:     options implementation
  7. ///////////////////////////////////////////////////////////////////////*/
  8.  
  9.  
  10. var ERR_GET_MODULE_PARSER = "Error: Cannot get Parser object for module";
  11. var arrOptions = new Array();
  12. var arrParser = new Array();
  13. var iRoutedPortListEnabled = true;
  14. var bIsAdmin = window.external.IsAdmin;
  15. var strDisabled = (!bIsAdmin || window.external.Managed == 1  &&  window.external.Context == 0) ? "disabled" : "";
  16. var arrProtos = new Array( "UDP4", "UDP6", "TCP4", "TCP6" );
  17. var arrProtoDescription = new Array();
  18. var arrCombos, arrLinks, arrExtPortEdits, arrIntPortEdits, arrServerAddrChks, arrServerAddrs;
  19. var idCreateButton = '';
  20. var HTML_ICO_MINUS = '<IMG src="ico-minus.gif" alt="Delete row"/>';
  21. var PROPID_ROUTEDPORTLIST = 'RoutedPortList',
  22.     PROPID_STEALTHMODE = 'PreventClosedPortAccess',
  23.     PROPID_NATPROCESSINGEN = 'NatProcessingEn';
  24. var PT_INT = 1,
  25.     PT_STR = 0;
  26. var strBuild = window.external.Build;
  27. var arrBuildNumbers = new Array("", "", "", "");  arrBuildNumbers = strBuild.split(".");
  28. var bNatIfaceEnabled = (window.external.StringProperty("fw-nat-options") != "" || parseInt(arrBuildNumbers[1]) >= 6);
  29.     
  30. var ID_ROUTEDPORTLIST = "id_listRoutedPorts";
  31. var STR_PROTO = "Protocol",
  32.     STR_EXT = "External Port#",
  33.     STR_INT = "Internal Port#",
  34.     STR_FTPCONTROL = "FTP Control Port",
  35.     STR_FTPIPADDR = "FTP Server IP Address";
  36.     
  37. function OnLoad()
  38. {
  39.     fw.innerHTML = GetModuleOptionsStr(2);
  40.     sbx.innerHTML = GetModuleOptionsStr(1);
  41.     //ids.innerHTML =    GetModuleOptionsStr(16);
  42. }
  43.  
  44. function OptionsInit()
  45. {
  46.     var i = 0;
  47.     for (i = 1; i <= 2; i++)
  48.         arrParser[i] = window.external.ServerParser(i) ;
  49.     arrProtoDescription["UDP4"] = "UDP v4";
  50.     arrProtoDescription["UDP6"] = "UDP v6";
  51.     arrProtoDescription["TCP4"] = "TCP v4";
  52.     arrProtoDescription["TCP6"] = "TCP v6";
  53. }
  54.  
  55. function GetModuleOptionsStr(ModuleID, bNatFwOptions)
  56. {
  57.     var Option, OptList, strOptions, Parser = null;
  58.     Parser = arrParser[ModuleID];
  59.     if (Parser == null)
  60.     {
  61.         return "";
  62.     }
  63.     strOptions ="";
  64.     OptList = new Enumerator(Parser.GlobalOptions);
  65.     if (bNatFwOptions)
  66.     {
  67.         strOptions += GetNatProcessingEnabled(null);
  68.         strOptions += GetRoutedPortList(null);
  69.         return strOptions;
  70.     }
  71.     for (;!OptList.atEnd();OptList.moveNext())
  72.        {
  73.         //add option to array
  74.         var prop = OptList.item();
  75.         arrOptions[arrOptions.length] = prop;
  76.         var strNewOption = "";
  77.         if (prop.PropertyID != PROPID_NATPROCESSINGEN &&
  78.             prop.PropertyID != PROPID_STEALTHMODE  &&
  79.             prop.PropertyID != PROPID_ROUTEDPORTLIST)
  80.             strNewOption = GetOptionStr(OptList.item(), ModuleID, bNatFwOptions);
  81.         strOptions += strNewOption;
  82.        }
  83.  
  84.     return strOptions;
  85. }
  86. //applies changes to parser
  87. function OnChange(Ctrl, ModuleID)
  88. {
  89.     var Parser = arrParser[ModuleID];
  90.     OptionList = Parser.GlobalOptions;
  91.     var OptionID, oOption, Value;
  92.     OptionID = Ctrl.name;
  93.     if (OptionID == "UnkAppStartDlg" || OptionID == "UnkSysAppStartDlg" || OptionID == "GuardSystemProcesses")
  94.         Value = Ctrl.checked?1:0;
  95.     else
  96.         Value = Ctrl.options[Ctrl.selectedIndex].value;
  97.     oOption = OptionList.Get(OptionID);
  98.     if (oOption)
  99.     {
  100.         oOption.Value = parseInt(Value);
  101.     }
  102.     
  103. }
  104. //return ful tag string for one parser option
  105. function GetOptionStr(Option, ModuleID, bNatFwOptions)
  106. {
  107.     var strOption="";
  108.     var strOptionID = Option.PropertyID;
  109.     switch(strOptionID)
  110.     {
  111.     case "SafeToInjectDllGroup":
  112.         break;
  113.     case "GuardSystemProcesses":
  114.         break;                // this option is disabled
  115.     case "UnkAppStartDlg": //checkbox
  116.         if (!bNatFwOptions)
  117.             strOption = GetCheckBoxHtml(Option, ModuleID);
  118.         break;
  119.     case "UnkSysAppStartDlg": //checkbox
  120.         if (!bNatFwOptions)
  121.             strOption = GetCheckBoxHtml(Option, ModuleID);
  122.         break;
  123.     case "PreventClosedPortAccess": //custom combo
  124.         if (!bNatFwOptions && !bNatIfaceEnabled)
  125.             strOption = GetPreventClosedPortAccessHtml(Option, ModuleID);
  126.         break;
  127.     default: //Audit levels
  128. //        if (!bNatFwOptions && (strOptionID != "ClosedPortAccessAL" | !bNatIfaceEnabled))
  129. //        {
  130.             strOption = GetALComboHtml(Option, ModuleID);
  131. //        }
  132.         break;
  133.     }
  134.     return strOption;
  135. }
  136. function GetCheckBoxHtml(Option, ModuleID)
  137. {
  138.     var strCode;
  139.     var Val ="";
  140.     if (Option.Value == 1)
  141.         Val = "CHECKED";
  142.     strCode = '<p align="left"><input type="checkbox" '+ Val + ' name="' + Option.PropertyID;
  143.     strCode += '"onclick="OnChange(this,'+ ModuleID+')" ' + strDisabled + '> ' + GetDisplayStr(Option.PropertyID) +'</p>'; 
  144.     return strCode;
  145. }
  146. function GetPreventClosedPortAccessHtml(Option, ModuleID)
  147. {
  148.     var strCode = "";
  149.     strCode += '<table><tr><td width="200">'+GetDisplayStr(Option.PropertyID)+'</td><td align="right">';
  150.     strCode += '<select name="'+ Option.PropertyID+'" OnChange = "OnChange(this,'+ ModuleID+')" ' + strDisabled + '>';
  151.     strCode +=    '<OPTION value=0 '+ (Option.Value==0?'SELECTED':'') +'>Disable</OPTION>';
  152.     strCode +=    '<OPTION value=1 '+ (Option.Value==1?'SELECTED':'') +'>Enable</OPTION>';
  153.     strCode +=    '<OPTION value=2 '+ (Option.Value==2?'SELECTED':'') +'>Enable For NAT (ICS)</OPTION>';    
  154.     strCode += '</select></td></tr></table>';
  155.     return strCode;
  156. }
  157.  
  158. function GetALComboHtml(Option, ModuleID)
  159. {
  160. //    if (!bNatFwOptions && !bNatIfaceEnabled)
  161.     strCode = '<table><tr><td width="200">'+GetDisplayStr(Option.PropertyID)+'</td><td align="right">';
  162.     strCode += '<select name="'+ Option.PropertyID+'" OnChange = "OnChange(this,'+ ModuleID+')" ' + strDisabled + '>';
  163.     strCode +=    '<OPTION value=0 '+ (Option.Value==0?'SELECTED':'') +'>Do Not Monitor</OPTION>';
  164.     strCode +=    '<OPTION value=1 '+ (Option.Value==1?'SELECTED':'') +'>Monitor</OPTION>';
  165. //    strCode +=    '<OPTION value=2 '+ (Option.Value==2?'SELECTED':'') +'>Alert</OPTION>;        // not currently supported
  166.     strCode +=  '</select></td></tr></table>';
  167.     return strCode;
  168. }
  169. function GetDisplayStr(PropID)
  170. {
  171.     var DisplayStr = PropID;
  172.     switch(PropID)
  173.     {
  174.         case "SBXChangeSecurityAL":     DisplayStr = "Windows Security Engine Status";break;
  175.         case "StartProcessAL":             DisplayStr = "Start process audit level";break;
  176.         case "EndProcessAL":            DisplayStr = "End process audit level";break;
  177.         case "ChangeConditionAL":        DisplayStr = "Change condition audit level";break;
  178.         case "ChangeProcConditionAL":    DisplayStr = "Change process condition audit level";break;
  179.         case "UnkAppStartDlg":            DisplayStr = "Alert when unknown application starts";break;
  180.         case "UnkSysAppStartDlg":            DisplayStr = "Alert when unknown system application starts";break;
  181.         case "FWChangeSecurityAL":        DisplayStr = "Network Security Engine Status";break;
  182.         case "PreventClosedPortAccess":    DisplayStr = "Stealth Mode";break;
  183.         case "ClosedPortAccessAL":        DisplayStr = "Closed Port Access";break;
  184.         case "GuardSystemProcesses":        DisplayStr = "Guard system processes"; break;
  185.         case "NatProcessingEn":            DisplayStr = "NAT/ICS processing enabled"; break;
  186.         case "RoutedPortList":            DisplayStr = "List of port numbers corresponding to the services running on your network that Internet users can access"; break;
  187.     }
  188.     return DisplayStr;
  189. }
  190. function GetNatProcessingEnabled(Option)
  191. {
  192.     var OptionList = null, oOption = Option;
  193.     if (null == oOption)
  194.     {
  195.         var Parser = arrParser[2];
  196.         OptionList = Parser.GlobalOptions;
  197.         try
  198.         {
  199.             oOption = OptionList.Get(PROPID_NATPROCESSINGEN);
  200.         } catch (e)
  201.         {
  202.         }
  203.     }
  204.     var strCode = '<table><tr><td width="200"><strong>'+GetDisplayStr(PROPID_NATPROCESSINGEN)+'</strong></td><td align="right">';
  205.     if (null != oOption)
  206.         iRoutedPortListEnabled = oOption.value;
  207.     else
  208.         iRoutedPortListEnabled = false;
  209.     var elemPortList = null;  elemPortList = document.all[ID_ROUTEDPORTLIST];
  210.     if (null != elemPortList)
  211.         elemPortList.disabled = !iRoutedPortListEnabled;
  212.         
  213.     strCode += '<input type="checkbox" ' + (iRoutedPortListEnabled ? "checked" : "") + 
  214.     ' onclick="EnableRoutedPortList(this.checked);"></input>';
  215.     strCode += '</td></tr></table>';
  216.     
  217.     return strCode;
  218. }
  219.  
  220. function EnableListGtws()
  221. {
  222.     if (listGtws.controlWindow)
  223.     {
  224.         listGtws.EnableWindow(bIsAdmin && iRoutedPortListEnabled);
  225.     }
  226.     else
  227.         setTimeout("EnableListGtws()", 30);
  228. }
  229.  
  230. function GetProtoComboBox( strProto, index )
  231. {
  232.     var strCode = '';
  233.     strCode += '<SELECT id="combo_' + index + '" onchange="EnableServerAddr(' + index + ', this.selectedIndex);Save();"';
  234.     if (!iRoutedPortListEnabled)
  235.         strCode += ' disabled';
  236.     strCode += '>';
  237.     arrCombos[index] = "combo_" + index;
  238.     var i = 0;
  239.     for (i = 0; i < arrProtos.length; i++)
  240.     {
  241.         strCode += '<OPTION value="' + arrProtos[i] + '"';
  242.         if (strProto == arrProtos[i])
  243.             strCode += ' selected';
  244.         strCode += '>' + arrProtoDescription[arrProtos[i]] + '</OPTION>';
  245.     }
  246.     strCode += '</SELECT>';
  247.     return strCode;
  248. }
  249.  
  250. function portNoOk(elem)
  251. {
  252.     var iPortNo = parseInt(elem.value);
  253.     if (isNaN(iPortNo) || iPortNo < 1 || iPortNo > 65535)
  254.     {
  255.         alert('Value "' + elem.value + '" is not a valid port number. Please enter a number in the range <1, 65535>.');
  256.         elem.value = elem.or_value;
  257.         return false;
  258.     }
  259.     return true;
  260. }
  261.  
  262. function ipAddOk(elem)
  263. {
  264.     var iAddr = elem.value;
  265.     var arrComp = iAddr.split('.');
  266.     var bSuccess = true;
  267.     if (arrComp.length == 4)
  268.     {
  269.         for (var i = 0; i < 4; i++)
  270.         {
  271.             var iComp = parseInt(arrComp[i]);
  272.             if (isNaN(iComp))
  273.             {
  274.                 bSuccess = false;
  275.                 break;
  276.             }
  277.         }
  278.     }
  279.     else
  280.         bSuccess = false;
  281.     if (!bSuccess)
  282.     {
  283.         alert('Value "' + elem.value + '" does not seem as a valid IP address. Please try again.');
  284.         elem.value = elem.or_value;
  285.     }
  286.     return bSuccess;
  287. }
  288.  
  289. function EnableServerAddr(index, protoIndex)
  290. {
  291.     var strElemChk = 'chk_' + index;
  292.     var strElemAddr = 'addr_' + index;
  293.     var elemChk = document.all[strElemChk], elemAddr = document.all[strElemAddr];
  294.     if (protoIndex == 2)
  295.     {
  296.         elemChk.disabled = false;
  297.         elemAddr.disabled = false;
  298.     }
  299.     else
  300.     {
  301.         elemChk.disabled = true;
  302.         elemAddr.disabled = true;
  303.     }
  304. }
  305.  
  306. function GetPortEdit( strExtInt, strValue, index )
  307. {
  308.     var strId = strExtInt + 'port_' + index;
  309.     if (strExtInt == "ext")
  310.         arrExtPortEdits[index] = strId;
  311.     else
  312.         arrIntPortEdits[index] = strId;
  313.     var strCode = '<input type=edit id="' + strId + '" value="' + strValue + '" onblur="if(portNoOk(this)) Save();" onfocus="this.or_value = this.value"; onchange="if(portNoOk(this)) Save();"';
  314.     if (!iRoutedPortListEnabled)
  315.         strCode += ' disabled';
  316.     strCode += '></input>';
  317.     return strCode;
  318. }
  319.  
  320. function GetDeleteLink( index )
  321. {
  322.     var strCode = '';
  323.     strCode += '<A href="#" id="';
  324.     var strIdLink = "link_" + index;
  325.     arrLinks[index] = strIdLink;
  326.     strCode +=  strIdLink + '"';
  327.     strCode += ' onclick="OnDelete(' + index + ')"';
  328.     if (!iRoutedPortListEnabled)
  329.         strCode += ' disabled';
  330.     strCode += '>' + HTML_ICO_MINUS + '</A>';
  331.     return strCode;
  332. }
  333.  
  334. function GetCreateButton( )
  335. {
  336.     var strCode = '';
  337.     idCreateButton = "button_create";
  338.     strCode += '<input type=button id="' + idCreateButton + '" value="Add Row" onclick="OnAddRow();"';
  339.     if (!iRoutedPortListEnabled)
  340.         strCode += ' disabled';
  341.     strCode += '></input>';
  342.     return strCode;
  343. }
  344.     
  345. function GetRoutedPortList(Option)
  346. {
  347.     var strDisabled = (iRoutedPortListEnabled && bIsAdmin ? '' : 'disabled');
  348.     var strCode = '<table style="margin-top:15pt;"><tr><td colspan="2"><strong>' + GetDisplayStr(PROPID_ROUTEDPORTLIST)+ '<strong></td></tr><tr><td align="left">';
  349.     strCode += '<div id=div_table>';
  350.     strCode += GetRoutedPortListTable(Option);
  351.     strCode += '</div>';
  352.     strCode += '</td></tr>';
  353.     strCode += '<tr><td align="left">' + GetCreateButton() + '</td></tr></table>';
  354.     
  355.     return strCode;
  356. }
  357.  
  358. function GetServerAddrChk( strId, strAddr, bState, bDisabled, index )
  359. {
  360.     var strChkId = strId + '_' + index;
  361.     var strOpt = '<input type="checkbox" id="' + strChkId + '"';
  362.     arrServerAddrChks[index] = strChkId;
  363.     if (bState)
  364.         strOpt += ' checked';
  365.     if (bDisabled || !iRoutedPortListEnabled)
  366.         strOpt += ' disabled';
  367.     strOpt += ' onclick="' + strAddr + '_' + index + '.disabled = !this.checked;Save();"></input>';
  368.     return strOpt;
  369. }
  370.  
  371. function GetServerAddrEdit( strId, strAddr, bDisabled, index )
  372. {
  373.     var strEditId = strId + '_' + index;
  374.     strRet = '<input type="edit" id="' + strEditId + '" value="' + strAddr + '"';
  375.     if (bDisabled || !iRoutedPortListEnabled)
  376.         strRet += ' disabled';
  377.     strRet += ' onblur="if(ipAddOk(this)) Save();" onfocus="this.or_value = this.value"; onchange="if(ipAddOk(this)) Save();" ' + (strAddr == "" ? "disabled" : "") + '></input>';
  378.     arrServerAddrs[index] = strEditId;
  379.     return strRet;
  380. }
  381.  
  382. function GetRoutedPortListTable(Option)
  383. {
  384.     var Parser = arrParser[2], oOption = Option, OptionList = null;
  385.     if (oOption == null)
  386.     {
  387.         OptionList = Parser.GlobalOptions;
  388.         try
  389.         {
  390.             oOption = OptionList.Get(PROPID_ROUTEDPORTLIST);
  391.         } catch (e)
  392.         {
  393.         }
  394.     }
  395.     var strCode = '<table style="margin-top: 10pt;" cellspacing="0" cellpadding="10" border="1" bordercolor="#000000" id="' + ID_ROUTEDPORTLIST + '" ' + strDisabled + '>';
  396.     strCode += '<tr><td><strong>' + STR_PROTO + '</strong></td><td><strong>' + STR_EXT + '</strong></td><td><strong>' + STR_INT + '</strong></td><td><strong>' + STR_FTPCONTROL + '</strong></td><td><strong>' + STR_FTPIPADDR + '</strong></td></tr>'
  397.     arrCombos = new Array();
  398.     arrLinks = new Array();
  399.     arrExtPortEdits = new Array();
  400.     arrIntPortEdits = new Array();
  401.     arrServerAddrChks = new Array();
  402.     arrServerAddrs = new Array();
  403.     
  404.     if (null != oOption)
  405.     {
  406.         var value = oOption.value;
  407.         var arrCouples = new Array;
  408.         if (null != value)
  409.             arrCouples = oOption.value.split(',');
  410.         var i = 0, n = arrCouples.length;
  411.         for (i = 0; i < n; i++)
  412.         {
  413.             try
  414.             {
  415.                 var strSingleRoute = arrCouples[i];
  416.                 var strAux0 = strSingleRoute.split("@");
  417.                 var strAddr = "";
  418.                 if (strAux0.length > 1)
  419.                     strAddr = strAux0[1];
  420.                 var arrAux1 = strAux0[0].split(":");
  421.                 var strProto = arrAux1[0];
  422.                 var arrPorts = arrAux1[1].split("/");
  423.                 var strPortExt = arrPorts[0], strPortInt = arrPorts[1];
  424.                 strCode += '<tr>';
  425.                 strCode += '<td>' + GetProtoComboBox( strProto, i )  + '</td>';
  426.                    strCode += '<td>' + GetPortEdit( 'ext', strPortExt, i ) + '</td>';
  427.                    strCode += '<td>' + GetPortEdit( 'int', strPortInt, i ) + '</td>';
  428.                 strCode += '<td>' + GetServerAddrChk( 'chk', 'addr', (strAddr != ""), (strProto != "TCP4"), i ) + '</td>';
  429.                 strCode += '<td>' + GetServerAddrEdit('addr', strAddr, (strProto != "TCP4"), i ) + '</td>';
  430.                 strCode += '<td>' + GetDeleteLink(i) + '</td>';
  431.                 strCode += '</tr>';
  432.             }
  433.             catch(e)
  434.             {
  435.             }
  436.         }
  437.     }
  438.     
  439.     strCode += '</table>';    
  440.     return strCode;
  441. }
  442.  
  443. function EnableRoutedPortList(bCheckBox)
  444. {
  445.     var bEnabled = bCheckBox && bIsAdmin;
  446.     var elemPortList = null;  elemPortList = document.all[ID_ROUTEDPORTLIST];
  447.     var Parser = arrParser[2];
  448.     OptionList = Parser.GlobalOptions;
  449.     var oOption = null;
  450.     try
  451.     {
  452.         oOption = OptionList.Get(PROPID_NATPROCESSINGEN);
  453.     } catch (e)
  454.     {
  455.         oOption = OptionList.CreateProperty();
  456.         oOption.PropertyID = PROPID_NATPROCESSINGEN;
  457.         oOption.Type = PT_INT;
  458.         OptionList.Insert(oOption);
  459.     }
  460.     oOption.value = bEnabled ? 1 : 0;
  461.     if (null != elemPortList)
  462.     {
  463.         elemPortList.disabled = !bEnabled;
  464.     }
  465.     var i = 0;
  466. //disable combo boxes
  467.     for (i = 0; i < arrCombos.length; i++)
  468.         document.all[arrCombos[i]].disabled = !bEnabled;
  469. //disable delete links
  470.     for (i = 0; i < arrLinks.length; i++)
  471.         document.all[arrLinks[i]].disabled = !bEnabled;
  472. //disable edit fields
  473.     for (i = 0; i < arrExtPortEdits.length; i++)
  474.         document.all[arrExtPortEdits[i]].disabled = !bEnabled;
  475.     for (i = 0; i < arrIntPortEdits.length; i++)
  476.         document.all[arrIntPortEdits[i]].disabled = !bEnabled;
  477.     for (i = 0; i < arrServerAddrChks.length; i++)
  478.         document.all[arrServerAddrChks[i]].disabled = !bEnabled;
  479.     for (i = 0; i < arrServerAddrs.length; i++)
  480.         document.all[arrServerAddrs[i]].disabled = !bEnabled;
  481. //disable create button
  482.     document.all[idCreateButton].disabled = !bEnabled;
  483.     listGtws.EnableWindow(bEnabled);
  484.     iRoutedPortListEnabled = bEnabled;
  485.  
  486. }
  487.  
  488. function OnDelete(index)
  489. {
  490.     if (iRoutedPortListEnabled)
  491.     {
  492.         arrCombos[index] = "";
  493.         Save();
  494.         Refresh();
  495.     }
  496. }
  497.  
  498. function GetNewRPLValue()
  499. {
  500.     var i = 0;
  501.     var proto, extport, intport;
  502.     var newVal = "";
  503.     var bNeedsDelimiter = false;
  504.     for (i = 0; i < arrCombos.length; i++)
  505.     {
  506.         if (bNeedsDelimiter)
  507.         {
  508.             newVal += ',';
  509.             bNeedsDelimiter = false;
  510.         }
  511.         if (arrCombos[i] == "")    // deleted item
  512.             continue;
  513.         var combo = document.all[arrCombos[i]];
  514.         proto = combo.options[combo.selectedIndex].value;
  515.         var edit = document.all[arrExtPortEdits[i]];
  516.         extport = edit.value;
  517.         edit = document.all[arrIntPortEdits[i]];
  518.         intport = edit.value;
  519.         newVal += proto + ":" + extport + "/" + intport;
  520.         var chk = document.all[arrServerAddrChks[i]];
  521.         if (!chk.disabled && chk.checked)
  522.         {
  523.             var editAddr = document.all[arrServerAddrs[i]];
  524.             newVal += "@" + editAddr.value;
  525.         }
  526.         bNeedsDelimiter = true;
  527.     }
  528.     return newVal;
  529. }
  530.  
  531. function Save()
  532. {
  533.     var Option, Parser = arrParser[2];
  534.     if (Parser == null)
  535.     {
  536.         alert("No parser");
  537.     }
  538.     var Option = null;
  539.     try
  540.     {
  541.         Option = Parser.GlobalOptions.Get(PROPID_ROUTEDPORTLIST);
  542.     }
  543.     catch (e)
  544.     {
  545.         Option = Parser.GlobalOptions.CreateProperty();
  546.         Option.Type = PT_STR;
  547.         Option.PropertyID = PROPID_ROUTEDPORTLIST;
  548.         Parser.GlobalOptions.Insert(Option);
  549.     }
  550.     Option.value = GetNewRPLValue();
  551. }
  552.  
  553. function Refresh()
  554. {
  555.     var Option, Parser = arrParser[2];
  556.     if (Parser == null)
  557.     {
  558.         alert("No parser");
  559.     }
  560.     var Option = null;
  561.     try
  562.     {
  563.         Option = Parser.GlobalOptions.Get("RoutedPortList");
  564.     } catch (e)
  565.     {
  566.     }
  567.     div_table.innerHTML = GetRoutedPortListTable(Option);
  568. }
  569.  
  570. function OnAddRow()
  571. {
  572.     var Option, Parser = arrParser[2], OptionList = null;
  573.     if (Parser == null)
  574.     {
  575.         alert("No parser");
  576.     }
  577.     var val = GetNewRPLValue();
  578.     if (val != "")
  579.         val += ",";
  580.     val += "UDP4:1/1";
  581.     var Option = null;
  582.     OptionList = Parser.GlobalOptions;
  583.     try
  584.     {
  585.         Option = OptionList.Get(PROPID_ROUTEDPORTLIST);
  586.     }
  587.     catch (e)
  588.     {
  589.         Option = OptionList.CreateProperty();
  590.         Option.Type = PT_STR;
  591.         Option.PropertyID = PROPID_ROUTEDPORTLIST;
  592.         OptionList.Insert(Option);
  593.     }
  594.     Option.value = val;
  595.     Refresh();
  596. }
  597.  
  598.